﻿<Window x:Class="_06.ResourceStyle.Style.BasedOnImplicitStyle"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="BasedOnImplicitStyle" Height="300" Width="300">
    <Window.Resources>
        <Style TargetType="GroupBox">
            <Setter Property="Margin" Value="10"/>
            <Setter Property="Padding" Value="10"/>
        </Style>
        <Style TargetType="Button">
            <Setter Property="Margin" Value="5"/>
            <Setter Property="Background" Value="Chartreuse"/>
            <Setter Property="Foreground" Value="Teal"/>
        </Style>
        <!--note: because implicit style doesn't have a explicit name
        so {x:Type control-class-name} automatically becomes its name, like below
        and pay attention that 'implict base style' and 'derived style' are in the same level-->
        <Style x:Key="specialBtnStyle" TargetType="Button"
               BasedOn="{StaticResource {x:Type Button}}">
            <Setter Property="Foreground" Value="Navy"/>
            <Setter Property="FontWeight" Value="Black"/>
        </Style>
    </Window.Resources>
    <StackPanel>
        <GroupBox Header="Original Implict Style">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Button Grid.Row="0" Grid.Column="0" Content="Button1"  />
                <Button Grid.Row="0" Grid.Column="1" Content="Button2"  />
            </Grid>
        </GroupBox>
        <GroupBox Header="Derived from Implicit Style">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Button Grid.Row="0" Grid.Column="0" Content="Button1"  
                        Style="{StaticResource specialBtnStyle}"/>
                <!--note: setting property directly always beat the property in style-->
                <Button Grid.Row="0" Grid.Column="1" Content="Button2" 
                        Foreground="Black"
                        Style="{StaticResource specialBtnStyle}"
                        />
            </Grid>
        </GroupBox>
    </StackPanel>
</Window>
